﻿using Ordering.Domain.Seedwork;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Ordering.Domain.AggregatesModel.OrderAggregate
{
    /// <summary>
    /// 小区
    /// </summary>
    public class ResidentialAreas
        : Entity, IAggregateRoot
    {
        /// <summary>
        /// 小区名字
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 小区地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 代理人ID
        /// </summary>
        public string AgentManId { get; set; }
        /// <summary>
        /// 经度
        /// </summary>
        [Column(TypeName = "decimal(18,8)")]
        public decimal? Longitude { get; private set; }
        /// <summary>
        /// 纬度
        /// </summary>
        [Column(TypeName = "decimal(18,8)")]
        public decimal? Latitude { get; private set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; private set; }
        /// <summary>
        /// 创建人Id
        /// </summary>
        public string CreateUserId { get; private set; }
        /// <summary>
        /// 快递地址
        /// </summary>
        private readonly List<ExpressAddress> _expressAddress;
        public IReadOnlyCollection<ExpressAddress> ExpressAddress => _expressAddress;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="name">小区名字</param>
        /// <param name="address">小区地址</param>
        /// <param name="agentManId">代理人Id</param>
        /// <param name="longitude">精度</param>
        /// <param name="latitude">纬度</param>
        public ResidentialAreas(string name,string address,string agentManId,string createUserId,decimal? longitude = null,decimal? latitude = null)
        {
            this.Name = name;
            this.Address = address;
            this.AgentManId = agentManId;
            this.Longitude = longitude;
            this.Latitude = latitude;
            this.CreateTime = DateTime.Now;
            this.CreateUserId = createUserId;
        }
    }
}
